package comandos.status;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class Online implements CommandExecutor {

    private final JavaPlugin plugin;

    public Online(JavaPlugin plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            String names = "";
            
            for (Player online : plugin.getServer().getOnlinePlayers()) {
                names += online.getDisplayName() + ", ";
            }

            player.chat(names);

            return true;
        } else {
            sender.sendMessage("Você precisa ser um jogador!");
        }
        return false;
    }
}
